<!DOCTYPE html>
<html lang="zh-CN">

<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Document</title>
</head>

<body>
  <script>
    window.setTimeout(function () {
      console.log(`时间到了`);
    }, 2000);
    let callback = function () {
      console.log(`好的了`);
    };
    window.setTimeout(callback, 3000); // 可以写成以下的方式
    window.setTimeout("callback()", 3000); //可以写成这样但不提倡
    let setId = window.setTimeout(callback, 5000); //给定时器起名字
  </script>
</body>

</html>